"""
-------------------------------
- File_Name: login.py
- Date: 2025/2/15
- Author: yangzhide
- Email: xxzjyzd@126.com
- Description: 用户认证相关Pydantic模型
-------------------------------
"""

from pydantic import BaseModel,Field
from app.utils.common import to_camel_case

class Empty(BaseModel):
    pass

class TokenData(BaseModel):
    username: str | None = None

class TokenBase(BaseModel):
    """前端token结构"""
    """成功token"""
    token: str
    """刷新token"""
    refreshToken: str
    """token类型"""
    token_type: str = 'Bearer'

class Token(BaseModel):
    """返回token"""
    code: str
    msg: str
    """fastapi Swagger token"""
    access_token: str
    """fastapi Swagger token刷新"""
    refresh_token: str
    """fastapi Swagger token类型"""
    token_type: str = 'Bearer'
    """前端token"""
    data: TokenBase

class RefreshTokenIn(BaseModel):
    """刷新token"""
    """刷新token"""
    refresh_Token: str = Field(serialization_alias='refreshToken')

class UserInfo(BaseModel):
    """用户信息"""

    """用户id"""
    id: int = Field(serialization_alias="userId")
    """用户名称"""
    user_name: str
    """用户编号"""
    user_code: str
    """用户角色"""
    roles: list[str] | None = None
    """用户按钮列表"""
    buttons: list[str] | None = None

    class Config:
        alias_generator = to_camel_case
        populate_by_name = True

"""常量路由"""

class ConstantMata(BaseModel):
    """常量路由Mata"""

    menu_name: str = Field(serialization_alias="title")
    i18n_key: str = Field(serialization_alias="i18nKey")
    constant: bool = Field(serialization_alias="constant")
    hide_in_menu: bool = Field(serialization_alias="hideInMenu")


class ConstantMenu(BaseModel):
    """常量路由"""
    menu_name: str = Field(serialization_alias="name")
    route_path: str = Field(serialization_alias="path")
    component: str = Field(serialization_alias="component")
    meta: ConstantMata

class RoleMenuIdsOut(BaseModel):
    """角色菜单权限的home及菜单id列表"""
    """角色默认主页"""
    role_home: str = Field(serialization_alias="roleHome")
    """角色拥有菜单id列表"""
    menu_ids: list[str|int] = Field(serialization_alias="menuIds")
    """角色拥有菜单按钮code列表"""
    menu_buttons: list[str] = Field(serialization_alias="menuButtons")
